package com.ruoyi.violation.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.violation.domain.VehicleViolationReport;
import com.ruoyi.violation.vo.CorrectVo;
import com.ruoyi.violation.vo.LawAuditVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.violation.mapper.ConstructionSiteViolationReportMapper;
import com.ruoyi.violation.domain.ConstructionSiteViolationReport;
import com.ruoyi.violation.service.IConstructionSiteViolationReportService;

/**
 * 项目违章上报信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-14
 */
@Service
public class ConstructionSiteViolationReportServiceImpl implements IConstructionSiteViolationReportService 
{
    @Autowired
    private ConstructionSiteViolationReportMapper constructionSiteViolationReportMapper;

    /**
     * 查询项目违章上报信息
     * 
     * @param id 项目违章上报信息主键
     * @return 项目违章上报信息
     */
    @Override
    public ConstructionSiteViolationReport selectConstructionSiteViolationReportById(Long id)
    {
        return constructionSiteViolationReportMapper.selectConstructionSiteViolationReportById(id);
    }

    /**
     * 查询项目违章上报信息列表
     * 
     * @param constructionSiteViolationReport 项目违章上报信息
     * @return 项目违章上报信息
     */
    @Override
    public List<ConstructionSiteViolationReport> selectConstructionSiteViolationReportList(ConstructionSiteViolationReport constructionSiteViolationReport)
    {
        return constructionSiteViolationReportMapper.selectConstructionSiteViolationReportList(constructionSiteViolationReport);
    }

    /**
     * 新增项目违章上报信息
     * 
     * @param constructionSiteViolationReport 项目违章上报信息
     * @return 结果
     */
    @Override
    public int insertConstructionSiteViolationReport(ConstructionSiteViolationReport constructionSiteViolationReport)
    {
        constructionSiteViolationReport.setCreateTime(DateUtils.getNowDate());
        return constructionSiteViolationReportMapper.insertConstructionSiteViolationReport(constructionSiteViolationReport);
    }

    /**
     * 修改项目违章上报信息
     * 
     * @param constructionSiteViolationReport 项目违章上报信息
     * @return 结果
     */
    @Override
    public int updateConstructionSiteViolationReport(ConstructionSiteViolationReport constructionSiteViolationReport)
    {
        constructionSiteViolationReport.setUpdateTime(DateUtils.getNowDate());
        return constructionSiteViolationReportMapper.updateConstructionSiteViolationReport(constructionSiteViolationReport);
    }

    /**
     * 批量删除项目违章上报信息
     * 
     * @param ids 需要删除的项目违章上报信息主键
     * @return 结果
     */
    @Override
    public int deleteConstructionSiteViolationReportByIds(Long[] ids)
    {
        return constructionSiteViolationReportMapper.deleteConstructionSiteViolationReportByIds(ids);
    }

    /**
     * 删除项目违章上报信息信息
     * 
     * @param id 项目违章上报信息主键
     * @return 结果
     */
    @Override
    public int deleteConstructionSiteViolationReportById(Long id)
    {
        return constructionSiteViolationReportMapper.deleteConstructionSiteViolationReportById(id);
    }

    @Override
    public int removeConstructionSiteViolationReportByIds(Long[] ids) {
        return constructionSiteViolationReportMapper.removeConstructionSiteViolationReportByIds(ids);
    }

    @Override
    public int audit(LawAuditVo lawAuditVo) {
        ConstructionSiteViolationReport constructionSiteViolationReport = constructionSiteViolationReportMapper.selectConstructionSiteViolationReportById(lawAuditVo.getId());
        constructionSiteViolationReport.setAuditStatus(lawAuditVo.getAuditStatus());
        constructionSiteViolationReport.setAuditUserId(lawAuditVo.getAuditUserId()+"");
        constructionSiteViolationReport.setAuditReason(lawAuditVo.getReason());
        return constructionSiteViolationReportMapper.updateConstructionSiteViolationReport(constructionSiteViolationReport);
    }

    @Override
    public int correct(CorrectVo correctVo) {
        Long id = correctVo.getId();
        ConstructionSiteViolationReport constructionSiteViolationReport = constructionSiteViolationReportMapper.selectConstructionSiteViolationReportById(id);
        constructionSiteViolationReport.setHandleImgUrl(correctVo.getImgUrl());
        constructionSiteViolationReport.setHandleContent(correctVo.getContent());
        return constructionSiteViolationReportMapper.updateConstructionSiteViolationReport(constructionSiteViolationReport);
    }
}
